﻿using System;
using System.Text;
using System.Xml;

namespace Bookworm.Core
{
    public sealed class XmlFrameSerializer : FrameSerializer<string>
    {
        public override string Serialize(Frame frame)
        {
            var sb = new StringBuilder();

            var writerSettings = new XmlWriterSettings();
            writerSettings.ConformanceLevel = ConformanceLevel.Document;
            writerSettings.Encoding = Encoding.UTF8;
            using (var writer = XmlWriter.Create(sb, writerSettings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("frame");
                writer.WriteAttributeString("id", "TODO"); //TODO: Extract the frame ID
                //TODO: Write the rest of the frame
                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
            return sb.ToString();
        }

        public override Frame Deserialize(string data)
        {
            throw new NotImplementedException();
        }
    }
}
